package kr.co.redcircle.service.oAuth.api.naver.me2day;

import net.sf.json.JSONObject;

import org.scribe.builder.api.DefaultApi20;
import org.scribe.model.OAuthConfig;
import org.scribe.model.OAuthRequest;
import org.scribe.model.Response;
import org.scribe.model.Verb;

public class Me2dayApi extends DefaultApi20{
	
	private static final String AUTHORIZE_URL = "http://me2day.net/api/get_auth_url.json?akey=%s";

	@Override
	public String getAccessTokenEndpoint() {
		return "http://me2day.net/api/start_auth";
	}

	@Override
	public String getAuthorizationUrl(OAuthConfig config) {
		
		String configAppKey = config.getApiKey();
		OAuthRequest request = new OAuthRequest(Verb.GET, String.format(AUTHORIZE_URL, configAppKey));
		Response response = request.send();
		System.out.println("resp : " + response.getBody());
		JSONObject respBody = JSONObject.fromObject(response.getBody());
		return respBody.getString("url");
		
	}


}
